﻿@using WXY.Course.Model;
@model IList<MenuInfo>
@{
    var paras = this.Request.Params;
}
<div class="m_rtop">
    <h3>
        <label>
            内容管理
        </label>
        <span>></span>目录管理
    </h3>
</div>
<p class="m_ptop">
    <input type="button" id="btnAdd" class="btn_bg1" value="新增目录">
</p>
<div class="m_box">
    <table width="980" cellpadding="0" cellspacing="0" border="1"
           class="tab1">
        <tr>
            <th width="150">操作</th>
            <th width="160">排序号</th>
            <th width="80">目录ID</th>
            <th width="160">目录名称</th>
            <th width="160">链接地址</th>
            <th width="160">在新标签页打开</th>
        </tr>
        @if (Model != null)
        {
            int index = 0;
            foreach (var item in Model)
            {
                index++;
                <tr>
                    <td align="center">
                        <input type="hidden" class="js_code" value="@item.Code">
                        <a href="@Url.Action("Edit", "Menu", new { Id = item.Code})" name="editLink">编辑</a>
                        <a href="javascript:void(0)" name="deleteLink">删除</a>
                        @*@if (index != 0)
                            {
                                <a href="javascript:void(0)" class="js_sort" data-value="0">向上</a>
                            }
                            @if (index != Model.Count)
                            {
                                <a href="javascript:void(0)" class="js_sort" data-value="1">向下</a>
                            }*@
                    </td>
                    <td align="center">@item.Order</td>
                    <td align="center">@item.Code</td>
                    <td>@item.Name</td>
                    <td>@item.Url</td>
                    <td>@item.TargetBlank</td>
                </tr>
            }
        }
    </table>
</div>

<script type="text/javascript">
    $(function () {
        $("#btnAdd").on("click", function () {
            location.href = "@Url.Action("Edit", "Menu")";
        });
        @*$("a.js_order").on("click", function () {
            var id = $(this).parent().find("input.js_code").val();
            var $type = $(this).attr("data-value");
            $.ajax({
                type: 'post',
                url: '@Url.Action("Sort","Menu")',
                data: { id: id, type: type },
                success: function (data) {
                    if (data.IsSuccess && data.Data > 0) {
                        location.reload();
                    } else {
                        art.dialog({
                            lock: true,
                            title: '提示',
                            content: "移动失败" + data.Message,
                            ok: function () {
                                this.close();
                            }
                        });
                    }
                }
            });
        });*@
        $("a[name='deleteLink']").on("click", function () {
            var e = this;
            art.dialog({
                lock: true,
                title: '提示',
                content: '确定要删除该目录么？',
                button: [
                    {
                        value: '确定',
                        callback: function () {
                            var id = $(e).parent().find("input.js_code").val();
                            $.ajax({
                                type: 'post',
                                url: '@Url.Action("Delete","Menu")',
                                data: { id: id },
                                success: function (data) {
                                    if (data.IsSuccess && data.Data > 0) {
                                        art.dialog({
                                            lock: true,
                                            title: '提示',
                                            content: '删除成功',
                                            ok: function () { location.reload(); }
                                        });
                                    } else {
                                        art.dialog({
                                            lock: true,
                                            title: '提示',
                                            content: "删除失败" + data.Message,
                                            ok: function () {
                                                this.close();
                                            }
                                        });
                                    }
                                }
                            });
                        }
                    },
                    {
                        value: '取消',
                        focus: true,
                        callback: function () {
                            this.close();
                        }
                    }
                ]
            });
        });
    });
</script>
